﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data.SqlClient;

namespace Agresso.Interface.Layer.Domain
{
    public class RoleMaster
    {
        long m_roleMasterID = 0;
        string m_roleName = string.Empty;
        DateTime m_cretnDate;
        long m_cretnBy = 0;
        DateTime m_modfctnDate;
        long m_modfctnBy = 0;

        //Hashtable m_roleDetails = new Hashtable();
        IDictionary<string, RoleDetail> m_roleDetails = new Dictionary<string, RoleDetail>();

        public RoleMaster() { }
        public RoleMaster(long id) 
        {
            m_roleMasterID = id;
        }
        public RoleMaster(SqlDataReader rd) 
        {
            m_roleMasterID = Convert.ToInt64(rd["role_master_id"]);
            m_roleName = rd["role_master_name"].ToString();
            m_cretnDate = Convert.ToDateTime(rd["cretn_date"]);
            m_cretnBy = Convert.ToInt64(rd["cretn_by"]);
            m_modfctnDate = Convert.ToDateTime(rd["modfctn_date"]);
            m_modfctnBy = Convert.ToInt64(rd["modfctn_by"]);
        }
        public long RoleMasterID
        {
            get { return m_roleMasterID; } 
        }
        public string RoleName
        {
            get { return m_roleName; }
            set { m_roleName = value; }
        }
        public DateTime CreatenDate
        {
            get { return m_cretnDate; }
            set { m_cretnDate = value; }
        }
        public long CreatenBy
        {
            get { return m_cretnBy; }
            set { m_cretnBy = value; }
        }
        public DateTime ModificationDate
        {
            get { return m_modfctnDate; }
            set { m_modfctnDate = value; }
        }
        public long ModificationBy
        {
            get { return m_modfctnBy; }
            set { m_modfctnBy = value; }
        }
        public IDictionary<string, RoleDetail> RoleDetails
        {
            get { return m_roleDetails; }
        }
        public RoleDetail this[string key]
        {
            get 
            {
                if (m_roleDetails.ContainsKey(key))
                    return m_roleDetails[key];
                else
                    return new RoleDetail();
            }
        }
        public void AddRoleDetails(RoleDetail rd)
        {
            rd.RoleMaster = this;
            m_roleDetails.Add(rd.FormName, rd);
        }
        public override string ToString()
        {
            return m_roleName;
        }
    }
}
